package com.common.util;

import com.alibaba.druid.support.json.JSONUtils;
import com.common.ResultCodeEnum;
import com.common.ResultUtil;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author HOU
 * @descripton
 * @date 2021/5/31
 */
@Component
public class HttpResponseUtil {

    public void write(HttpServletResponse response, ResultCodeEnum resultCodeEnum) throws IOException {
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONUtils.toJSONString(ResultUtil.result(resultCodeEnum)));
    }
}
